/**
 * Created by admin on 2017/5/22.
 */
export const time16 = function(v){
  if(!v) return;
  return v.substring(0,16)
};
//时间过去多久
export const howLong = function (v) {
  const t = new Date().getTime() - new Date(v.replace(/-/g,"/")).getTime(),
    timeMap = {
      d: 86400000,
      h: 3600000,
      m: 60000,
      s: 1000
    },
    d = Math.floor(t/timeMap.d),
    h = Math.floor(t/timeMap.h%24),
    m = Math.floor(t/timeMap.m%60),
    s = Math.floor(t/timeMap.s%60);
  switch(true){
    case d>0:
      return d+'天前';
    case h>0:
      return h+'小时前';
    case m>0:
      return m+'分钟前';
    case s>0:
      return s+'秒前';
  }
};
export const chubAcStatus = function (v) {
  return {
    0: '报名未开始',
    1: '活动报名中',
    2: '报名已截止',
    3: '活动已结束',
    4: '报名已截止',
    5: '活动已满额',
  }[v];
};

export const select_time = function (v1, v2) {
  if(v1 && v2) {
    const weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      date1 = v1.substring(0,10),
      date2 = v2.substring(0,10),
      _date1 = date1.replace(/-/g,"/"),
      _date2 = date2.replace(/-/g,"/"),
      day1 = weekDay[new Date(date1).getDay()],
      day2 = weekDay[new Date(date2).getDay()],
      time1 = v1.substring(11,16),
      time2 = v2.substring(11,16);
    if(date1==date2){
      return _date1 +' '+ day1 +' '+ time1 + '-' + time2;
    }else{
      return _date1 +' '+ day1 +' '+ time1 + ' - ' + _date2 +' '+ day2 +' '+ time2;
    }
  }
};
